package com.shaw.study.test;

import com.shaw.study.springx.annotation.Autowired;
import com.shaw.study.springx.annotation.Controller;
import com.shaw.study.springx.annotation.RequestMapping;
import com.shaw.study.springx.annotation.RequestParam;
import com.shaw.study.springx.webmvc.ModelAndView;
import com.shaw.study.test.service.DemoService;
import com.shaw.study.test.service.IDemoService;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by asus on 2018/4/26.
 */
@Controller
public class DemoController {
    @Autowired
    IDemoService demoService;

    @RequestMapping("/demo/getName")
    public String getName(){
        return demoService.getName();
    }
    @RequestMapping("/index.html")
    public ModelAndView toIndex(@RequestParam("username")String userName){
        String viewName="index.html";
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("username",demoService.getName()+userName);
        return new ModelAndView(viewName,map);
    }
}
